function login() {
    var loginname = $.trim($("#loginname").val());
    var loginpassword = $.trim($("#loginpassword").val());
    if(loginname == ""){
        alert("请输入登录名");
        return false;
    }else if(loginpassword == ""){
        alert("请输入密码");
        return false;
    }
    //ajax去服务器端校验
    $.ajax({
        url :   "http://192.168.0.107:8080/userCore/user/mobile/login",
        type:   "post",
        data:JSON.stringify({
            loginName : loginname,
            loginPassword  : loginpassword,
        }),
        contentType:"application/json;",
        success:function(data) {
            var num = new Object;
            num.cp_keynum ="key_num";
            num.cp_num_value = data;
            var str = JSON.stringify(num); // 将对象转换为字符串
            localStorage.setItem(num.cp_keynum,str);

            window.data = data;
            if(data.code==0){
                location.href ="index.html";
            }else{
                alert("登户名或者密码不正确");
            }
        }
    });
}

   
